<template>
  <div class="place">
    <van-nav-bar style="background-color: #DBECFE;" left-arrow title="地点" @click-left="emit('back')" />
    <div class="imgList">
      <div class="imgItem" v-for="(item,key) in addrList" @click="selected(key)">
        <van-image radius="6px" width="80" height="80" :src=getImgUrl(item) />
        <span class="title">{{ key }}</span>
      </div>
    </div>
  </div>
</template>

<script setup>
import {onMounted, ref} from "vue";
import {getAllCityInfo, getImgUrl} from "@/api/index.js";
const addrList = ref({})

const emit = defineEmits(['back', 'imgClick'])

const selected = (item) => {
  emit('imgClick', item)
}


onMounted(async() => {
  const response = await getAllCityInfo()
  addrList.value = response.data
})
</script>

<style lang="scss" scoped>
.place {
  width: 100%;
  height: 100%;
  padding: 16px;
  background-color: #DBECFE;

  .imgList {
    display: flex;
    flex-wrap: wrap;
    margin-top: 10px;

    .imgItem {
      position: relative;
      width: 25%;
      margin: 10px;

      .title {
        position: absolute;
        bottom: 10px;
        width: 100%;
        text-align: center;
        left: 50%;
        transform: translateX(-50%);
        color: #fff;
        font-size: 12px
      }
    }
  }
}
</style>
